package com.pakazaka.roguelike.ui;

import com.pakazaka.enums.ItemPropertyType;
import com.pakazaka.simplecrawler.SimpleCrawler;
import static com.pakazaka.simplecrawler.Window.getWrappedString;
import com.pakazaka.testItemsSystem.Item;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;

/**
 *
 * @author Remi
 */
public class ItemDescWindow {

    private Item item;
    private static final int X_OFFSET = 14;

    public void paint(Graphics g) {
        g.setFont(new Font("Consolas", Font.BOLD, 16));
        g.setColor(Color.black);
        g.fillRect(0, 0, SimpleCrawler.windowWidth, SimpleCrawler.windowHeight);
        g.setColor(Color.white);
        g.drawRect(6, 6, SimpleCrawler.windowWidth - 18, SimpleCrawler.windowHeight - 42);
        g.drawString(item.getName().toUpperCase(), X_OFFSET, 24);

        String str[] = getWrappedString(item.getDescription(), 100);

        for (int i = 0; i < str.length; i++) {
            g.drawString(str[i], X_OFFSET, 48 + i * 24);
        }

        ArrayList<String> actions = new ArrayList<>();

        //try to equip the item
        if (item.isPropertyExist(ItemPropertyType.CAN_WEAR)) {
            actions.add("w - wear");
            actions.add("W - wield");
        }

        //try to eat-drink-etc the item
        if (item.isPropertyExist(ItemPropertyType.CAN_DRINK)) {
            actions.add("c - consume");
        }

        if (item.isPropertyExist(ItemPropertyType.CAN_EAT)) {
            actions.add("c - consume");
        }

        actions.add("d - drop");
        actions.add("t - throw");
        //drawing all the actions
        for (int i = 0; i < actions.size(); i++) {
            g.drawString(actions.get(i), X_OFFSET, 128 + i * 24);
        }
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }
}
